home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / haeberli / libgutil / tl.c < prev    next >
C/C++ Source or Header  |  1994-08-01  |  2KB  |  63 lines

  1. /*
  2.  * Copyright 1992, 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. /*
  18.  *    tl -
  19.  *        tri list file io stuff follows
  20.  *
  21.  *
  22.  */
  23. #include "stdio.h"
  24. #include "trilist.h"
  25.  
  26. static FILE *inf;
  27.  
  28. tlopen(name)
  29. char *name;
  30. {
  31.     int nbytes, ntri;
  32.     short magic;
  33.     trilisttri tri;
  34.  
  35.     inf = fopen(name,"r");
  36.     if(!inf) {
  37.     fprintf(stderr, "tldraw: can't read %s\n",name);
  38.     exit(1);
  39.     }
  40.     fread(&magic,sizeof(short),1,inf);
  41.     if(magic != TLMAGIC) {
  42.     fprintf(stderr, "tldraw: bad magic in input file\n");
  43.     exit(1);
  44.     }
  45.     nbytes = sizeoffile(inf);
  46.     nbytes -= sizeof(short);
  47.     if( (nbytes % sizeof(trilisttri)) != 0)
  48.     fprintf(stderr, "tldraw: strange file length!!\n");
  49.     ntri = nbytes / sizeof(trilisttri);
  50.     return ntri;
  51. }
  52.  
  53. tlread(tri)
  54. trilisttri *tri;
  55. {
  56.     fread(tri,sizeof(trilisttri),1,inf);
  57. }
  58.  
  59. tlclose()
  60. {
  61.     fclose(inf);
  62. }
  63.